/*
 * Copyright (C) 2011 Mette Bank, Rikke Jensen, Kenneth Brodersen, Thomas Pedersen
 * 
 * This file is part of digiPECS.
 * 
 * digiPECS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * digiPECS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with digiPECS.  If not, see <http://www.gnu.org/licenses/>.
 */

package sw6.digipecs.widget.admin;

import sw6.digipecs.interfaces.OnDropListener;
import sw6.digipecs.widget.dragdrop.DropTarget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.GridView;

public class PECSBookView extends GridView implements DropTarget {
	
	// TODO KENNETH: Remove onDropListener and implement the code directly in here, instead of activity -- Listener interface should be fully deleted afterwards 
	
	private OnDropListener mDropListener = null; 
	
	public void setOnDropListener(OnDropListener listener)
	{
		this.mDropListener=listener; 
	}
	
	public PECSBookView(Context context) {
		super(context);
	}
	
	public PECSBookView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	public PECSBookView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	
	@Override
	public boolean drop(View view, int x, int y) {
		if(mDropListener!=null)
			if (mDropListener.onDrop(view)) {
				view.setVisibility(VISIBLE);
				return true;
			} else {
				return false;
			}
		else
			return false;
	}
	
	@Override
	public void onDragOut() {
	}
	
	@Override
	public void onDragIn(int x, int y) {
	}
}
